package cn.idu.jvmtest;

public class P2_04_NoVisibility {
    private static boolean ready = false;
    private static int number;

    static class ReaderThread extends Thread {
        @Override
        public void run() {
            while (!ready) {
                System.out.println("number:" + number);
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        new ReaderThread().start();

        Thread.sleep(1000);
        number = 42;
        ready = true;
        Thread.sleep(10000);
    }

}
